import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RebateRecordVO, RebateRecordForm, RebateRecordQuery } from '@/api/business/rebateRecord/types';

/**
 * 查询返利记录列表
 * @param query
 * @returns {*}
 */

export const listRebateRecord = (query?: RebateRecordQuery): AxiosPromise<RebateRecordVO[]> => {
  return request({
    url: '/business/rebateRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询返利记录详细
 * @param id
 */
export const getRebateRecord = (id: string | number): AxiosPromise<RebateRecordVO> => {
  return request({
    url: '/business/rebateRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增返利记录
 * @param data
 */
export const addRebateRecord = (data: RebateRecordForm) => {
  return request({
    url: '/business/rebateRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改返利记录
 * @param data
 */
export const updateRebateRecord = (data: RebateRecordForm) => {
  return request({
    url: '/business/rebateRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除返利记录
 * @param id
 */
export const delRebateRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/rebateRecord/' + id,
    method: 'delete'
  });
};
